﻿<Window x:Class="DataBinding.BindToLinqFilteredCollection"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="BindToLinqFilteredCollection" Height="500" Width="347.6" MinHeight="500"
    >
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="*"></RowDefinition>
			<RowDefinition Height="Auto"></RowDefinition>			
			<RowDefinition Height="*"></RowDefinition>
		</Grid.RowDefinitions>

		<Grid>
			<Grid.RowDefinitions>
				<RowDefinition Height="*"></RowDefinition>
				<RowDefinition Height="Auto"></RowDefinition>
				<RowDefinition Height="Auto"></RowDefinition>
			</Grid.RowDefinitions>

			<ListBox Name="lstProducts" Margin="5,0" DisplayMemberPath="ModelName"
                SelectionChanged="lstProducts_SelectionChanged"></ListBox>
                
			<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="5,2,5,5" HorizontalAlignment="Right">
				<TextBlock VerticalAlignment="Center">Minimum Cost:</TextBlock>
				<TextBox Name="txtMinimumCost" Margin="5,0" Width="40" Text="100"></TextBox>
				<Button Margin="2,0,0,0"  Padding="2"
              Click="cmdGetProducts_Click">Get Products</Button>
			</StackPanel>
			
			<StackPanel Grid.Row="2" HorizontalAlignment="Right" Orientation="Horizontal" Margin="5,2,5,10">
				<Button Margin="2,0,0,0"  Padding="2"
                Click="cmdDeleteProduct_Click">Delete Selected</Button>
				<Button Margin="2,0,0,0" 
                Click="cmdAddProduct_Click" Padding="2">Add New</Button>
			</StackPanel>
		</Grid>

		<GridSplitter Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" ResizeBehavior="PreviousAndNext"
                          
              Height="5"
    ></GridSplitter>
		<Border Grid.Row="3" Padding="7" Margin="7" Background="LightSteelBlue">
			<Grid DataContext="{Binding ElementName=lstProducts, Path=SelectedItem}" TextBox.TextChanged="txt_TextChanged">
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto"></ColumnDefinition>
					<ColumnDefinition></ColumnDefinition>
				</Grid.ColumnDefinitions>
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto"></RowDefinition>
					<RowDefinition Height="Auto"></RowDefinition>
					<RowDefinition Height="Auto"></RowDefinition>
					<RowDefinition Height="Auto"></RowDefinition>
					<RowDefinition Height="*"></RowDefinition>
				</Grid.RowDefinitions>

				<TextBlock Margin="7">Model Number:</TextBlock>
				<TextBox Margin="5" Grid.Column="1" Text="{Binding Path=ModelNumber}"></TextBox>
				<TextBlock Margin="7" Grid.Row="1">Model Name:</TextBlock>
				<TextBox Margin="5" Grid.Row="1" Grid.Column="1" Text="{Binding Path=ModelName}"></TextBox>
				<TextBlock Margin="7" Grid.Row="2">Unit Cost:</TextBlock>
				<TextBox Margin="5" Grid.Row="2" Grid.Column="1" Text="{Binding Path=UnitCost}"></TextBox>
				<TextBlock Margin="7,7,7,0" Grid.Row="3">Description:</TextBlock>
				<TextBox Margin="7" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" 
                 TextWrapping="Wrap" VerticalScrollBarVisibility="Visible" Text="{Binding Path=Description}"></TextBox>


			</Grid>
		</Border>
	</Grid>
</Window>
